# -*- coding: utf-8 -*-

from django.http import Http404
from django.views.generic import list_detail

from settings import ALBUM_TYPES    # DEBUG
from gallery.models import Album, Picture

# Create your views here.

def index(request):
    raise Http404(u'Корень')

def list_albums(request, alb_type):
    title = [pair[1] for pair in ALBUM_TYPES if pair[0] == alb_type][0]
    return list_detail.object_list(
                   request,
                   queryset=Album.objects.filter(kind=alb_type),
                   template_object_name="album",
                   extra_context={'title': title})

def list_images(request, album_id):
    return list_detail.object_list(
                   request,
                   queryset=Picture.objects.filter(of_album=album_id),
                   template_object_name="picture",
                   extra_context={'title': Album.objects.get(id=album_id).name})
